//拿到一个axios实例 可以使用这个axios实例去发送请求
import request from '@/utils/request'
//品牌接口的前缀  /admin/product/baseTrademark
const api_name = '/admin/product/baseTrademark'

export default {
  /*根据id获取品牌数据   GET /admin/product/baseTrademark/get/{id}*/
  getTrademarkByID(trademarkId) {
    return request.get(`${api_name}/get/${trademarkId}`)
  },

  /*获取所有的品牌数据  GET /admin/product/baseTrademark/getTrademarkList*/
  getAllTrademark() {
    return request.get(`${api_name}/getTrademarkList`)
  },

  /*根据id删除品牌数据 DELETE /admin/product/baseTrademark/remove/{id}*/
  delTrademarkByID(trademarkId){
    return request.delete(`${api_name}/remove/${trademarkId}`)
  },

  /*新增品牌 POST /admin/product/baseTrademark/save*/
  addTrademark({logoUrl,tmName}){
    return request.post(`${api_name}/save`,{logoUrl,tmName})
  },

  /*根据id修改品牌 PUT /admin/product/baseTrademark/update*/
  updateTrademark({id,logoUrl,tmName}){
    return request.put(`${api_name}/update`,{id,logoUrl,tmName})
  },

  /*如果有id做修改 如果没有id做新增*/
  addAndUpdate({id,logoUrl,tmName}){
    if(id)
      return request.put(`${api_name}/update`,{id,logoUrl,tmName})
    else
      return request.post(`${api_name}/save`,{logoUrl,tmName})
  },

  /*分页查询品牌 GET /admin/product/baseTrademark/{page}/{limit}*/
  getAllTrademarkByPage(page,limit){
    return request.get(`${api_name}/${page}/${limit}`)
  }
}
